CC = gcc
PP = gcc
AR = ar rcv
ifeq ($(windir),)
EXE =
RM = rm -f
RMDIR = rm -rf
else
EXE = .exe
RM = del
RMDIR = rmdir /Q /S
endif

CFLAGS = -O2 -Os -D BSPATCH_EXECUTABLE -fno-exceptions -fvisibility=hidden -ffunction-sections -fdata-sections -Wextra -fno-exceptions
LDFLAGS = -Wl,--gc-sections,--print-gc-sections
INC = -I.

UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Darwin)
    LDFLAGS += -dead_strip
else
    LDFLAGS +=
endif

all:bspatch.o Bspatch$(EXE)

bspatch.o:bspatch.c
	$(CROSS_COMPILE)$(PP) -o $@ $(CFLAGS) -c $< $(INC)

Bspatch$(EXE):bspatch.o
	$(CROSS_COMPILE)$(PP) -o $@ $^ $(LDFLAGS) -s

clean:
	-$(RM) $(all)
